package com.ciaojian.store.service;

import com.ciaojian.core.mapper.OrderMapper;
import com.ciaojian.core.mapper.StoreFirstCostMapper;
import com.ciaojian.core.model.StoreFirstCost;
import com.ciaojian.core.service.StoreFirstCostService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 * 加盟门店初始成本表 服务类
 * </p>
 *
 * @author Atlakyn
 * @since 2021-05-08
 */
@Service
public class StoreFirstCostServiceImpl extends StoreFirstCostService<StoreFirstCostMapper, StoreFirstCost> {
    @Resource
    private OrderMapper orderMapper;

    /**
     * 投资回报率
     *
     * @param storeId 门店Id
     * @return 投资回报
     */
    public Map<String, BigDecimal> investAndBack(Integer storeId) {
        Map<String, BigDecimal> investAndBack = new HashMap<>(2);
        // 开店成本
        investAndBack.put("costTotal", baseMapper.getCostTotal(storeId));
        investAndBack.put("back", orderMapper.sumPayTotal(storeId));
        return investAndBack;
    }

}
